package com.fizzkai.p2p.mgrsite.controller;

import com.fizzkai.p2p.bussness.domain.PlatformBankInfo;
import com.fizzkai.p2p.bussness.domain.RechargeOffline;
import com.fizzkai.p2p.bussness.query.RechargeOfflineQuery;
import com.fizzkai.p2p.bussness.service.IPlatformBankInfoService;
import com.fizzkai.p2p.bussness.service.IRechargeOfflineService;
import com.fizzkai.p2p.core.domain.BaseAuthDomain;
import com.fizzkai.p2p.core.util.AjaxResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class RechargeOfflineController {

    @Autowired
    private IRechargeOfflineService rechargeOfflineService;
    @Autowired
    private IPlatformBankInfoService bankInfoService;


    /**
     * 充值 待审核 列表
     * @param qo
     * @param model
     * @return
     */
    @RequestMapping("/rechargeOffline")
    public String rechargeOffline(@ModelAttribute("qo") RechargeOfflineQuery qo, Model model){

        PageInfo<RechargeOffline> pageInfo = rechargeOfflineService.query(qo);
        List<PlatformBankInfo> banks = bankInfoService.list();
        model.addAttribute("pageInfo", pageInfo);
        model.addAttribute("banks", banks);
        return "rechargeoffline/list";
    }

    /**
     * 充值审核 的 提交
     * @return
     */
    @RequestMapping("/rechargeOffline_audit")
    @ResponseBody
    public Object rechargeOffline_audit(Long id, Integer state, String remark){
        rechargeOfflineService.audit(id, state, remark);
        return new AjaxResult(state == BaseAuthDomain.STATE_PASS? "审核成功" :"拒审成功·");
    }
}
